package com.mis.clothespos.shiro.permission.service.impl;

import com.mis.clothespos.shiro.permission.mapper.permissionMapper;
import com.mis.clothespos.shiro.permission.service.permissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
@Primary
public class permissionServiceImpl implements permissionService {

    @Autowired
    permissionMapper p;
    @Override
    public Set<String> selectPermsByUserId(Long userId) {
        List<String> perms = p.selectPermsByUserId(userId);
        Set<String> permsSet = new HashSet<>();
        for (String perm : perms)
        {
            if (perm!=null)
            {
                System.out.println(Arrays.asList(perm.trim().split(",")));
                permsSet.addAll(Arrays.asList(perm.trim().split(",")));
            }
        }
        return permsSet;
    }
}
